﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${pageContext.request.contextPath}/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<%@ include file="base.jsp" %>
<script src="${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript"></script>   
<script src="${pageContext.request.contextPath}/js/base.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerGrid.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerForm.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDateEditor.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerComboBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerCheckBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerRadio.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerSpinner.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTextBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/inject.js" type="text/javascript"></script> 
<script src="${pageContext.request.contextPath}/js/ligerPopupEdit.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDialog.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTip.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.metadata.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/messages_cn.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/ligerUiCommon.js" type="text/javascript"></script>  
<script src="${pageContext.request.contextPath}/js/common/ajax.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/dateFormateUtil.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ajaxupload.3.6.js" type="text/javascript"></script>
<script type="text/javascript"> 
	//添加校验
	$(function() {
		addValidate(submitData);
		$("form").ligerForm();
	});
	
		//初始化
		$(function() {
			var obj = eval(${rowJsonStringData});
			if("${isReadOnly}") {//查看
				setView("xh", obj.xh);
				setView("splx", obj.splx);
				setView("mc", obj.mc);
				setView("sl", obj.sl);
				setView("cj", obj.cj);
				setView("jj", obj.jj);
				setView("pfj", obj.pfj);
				setView("lsj", obj.lsj);
				setView("lrsj", formatDate(obj.lrsj, "yyyy-MM-dd HH:mm:ss"));//更新时间
				return;
			}
			//编辑
			if(obj) {
				$("#spId").val(obj.id);
				$("#xh").val(obj.xh);
				$set("splx", obj.splx);
				$("#mc").val(obj.mc);
				$("#sl").val(obj.sl);
				$("#cj").val(obj.cj);
				$("#jj").val(obj.jj);
				$("#pfj").val(obj.pfj);
				$("#pfj").val(obj.pfj);
				$("#lsj").val(obj.lsj);
			}
		$("#lrsj").text(formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));//录入时间
	});
		
		
	$(function(){	
		var button = $('#uploadfile'), interval;
		var data=new Object();
		//data.action="upload";
		new Ajax_upload(button,{
			action: "${pageContext.request.contextPath}/FileUploadAction",
			name: 'upfile',
			data:{id:''},
			responseType:false,
			onSubmit : function(file, ext){	
				if(ext!='bmp' && ext!='gif' && ext!='jpeg' && ext!='png' && ext!='jpg'){
					$.ligerDialog.warn("对不起，您只能导入图片文件");
					return false;
				}
				$.ligerDialog.waitting('正在导入中,请稍候...');
			},
			onComplete: function(file, response){
				$.ligerDialog.success(response, function(){
					$.ligerDialog.closeWaitting();
					//manager.reload();
				});
			}
		});
	});

	//提交商品信息
	function submitData() {
		if($("#error_xh").html() != null && $("#error_xh").html().length != 0) {
			return;
		}
		
		var sp = {};
		sp.id = $("#spId").val();
		sp.xh = $("#xh").val();// 型号
		sp.splx = $("#splx").val();// 类型
		sp.mc = $("#mc").val();// 名称
		sp.sl = $("#sl").val();// 数量
		sp.cj = $("#cj").val();// 厂家
		sp.jj = $("#jj").val();// 进价
		sp.pfj = $("#pfj").val();// 批发价
		sp.lsj = $("#lsj").val();// 零售价
		sp.userid = "${user.id}";
		sp.lrsj = $("#lrsj").text();//录入时间
		
		var url = "${pageContext.request.contextPath}/HwglAction?control=saveSpxx";
		sendAjaxRequest(url, JSON.stringify(sp), false, function(msg) {
			if(msg.data == "保存成功") {
				$.ligerDialog.success("保存成功", "提示", function(){
					//document.getElementById("backup").click();
				});
			} else {
				$.ligerDialog.error(msg.data);
			}
		});
	}
	
	//检测型号是否存在
	function checkXh() {
		var xh = $("#xh").val();
		if(xh == null || xh.length == 0) {
			return false;
		}
		var url = "${pageContext.request.contextPath}/HwglAction?control=checkXh&xh=" + xh;
		sendAjaxRequest(url, null, true, function(resData) {
			if(resData.data == "true") {
				$("#error_xh").html("该型号已存在，不能输入相同的型号");	
			} else {
				$("#error_xh").html("");
			}
		});
	}
	
	function setView(id, val) {
		var t = document.getElementById(id);
		while(t.tagName != "TD") {
			t = t.parentNode;
		}
		t.innerHTML = val;
	}
	
	//刷新页面
	function clearInput() {
		location.reload();
	}
</script>
<!--[if IE 6]>
   <script src="js/DD_belatedPNG.js"></script>
   <script>DD_belatedPNG.fix('.xxjbb_5 img');</script>
<![endif]-->
<title></title>
</head>
<style type="text/css">
body{background:#ffffff}
html{_overflow-y:scroll;}
</style>
<body>
<div class="xxjbb_position">
<table width="100%" align="left" cellpadding="0" cellspacing="0">
  <tr>
    <td class="xxjbb_1 xxjbb_3">
     <ul>
       <li class="xxjbb_1_block"><a id="backup" href="${pageContext.request.contextPath}/jsp/hwgl.jsp"><span><<</span>返回</a></li>
       <li><a href="#" onclick="javascript:$('#hwglForm').submit();">保存</a></li>
       <li><a href="#" onclick="clearInput()">重置</a></li>
     </ul>
   </td>
  </tr>
</table>
</div>
<div class="xxjbb_4">
 <form id="hwglForm" name="hwglForm" method="post" >
  <table width="100%" align="left" cellpadding="0" cellspacing="0" class="bjkcxx">
  <input type="hidden" id="spId" />
      <tr>
        <td class="xxjbb_mc" width="20%"><b>名称</b></td>
        <td class="xxjbb_mccc" width="80%"><b>值</b></td>
      </tr>
      <tr>
        <td class="xxjbb_b">型号*</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input onblur="checkXh()" id="xh" type="text" validate="{required:true, maxlength:10}"/></td>
              <td><div id="error_xh" class="xxjbb_9"></div></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">类型*</td>
        <td class="xxjbb_zzz">
        	<table>
            	<tr>
          			<td>
          				<select id="splx">
          					<option value="吊灯">吊灯</option> 
          					<option value="镜前灯">镜前灯</option>
          				</select>
          			</td>
          		</tr>
          	</table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">名称</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input   id="mc" name="mc" type="text"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">数量*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input    id="sl" name="sl" type="text" validate="{required:true,digits:true,maxlength:5}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">厂家</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input   id="cj" name="cj" type="text"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">进价*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input   id="jj" name="jj" type="text"  validate="{number:true,required:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">批发价*</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input  id="pfj" name="pfj" type="text" validate="{number:true, required:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">零售价*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input  id="lsj" name="lsj" type="text"  validate="{number:true, required:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">录入时间</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td id="lrsj"></td>
            </tr>
          </table>
        </td>
      </tr>
    <!--    <tr>
        <td class="xxjbb_z">附件</td>
        <td class="xxjbb_zzz xxjbb_2 xxjbb_6">
             <ul>
               <li class="xxjbb_1_block" id='uploadfile'><a href="#" >上传</a></li>
             </ul>
        </td>
      </tr> -->
    </table>
    </form>
</div>
<!-- 
<div class="xxjbb_8">
 <table width="100%" align="left" cellpadding="0" cellspacing="0" class="bjkcxx" style="margin:10px 0 0 0">
      <tr>
         <td class="xxjbb_mc"><b>文件名</b></td>
         <td class="xxjbb_mc"><b>文件描述</b></td>
         <td class="xxjbb_mc"><b>上传人</b></td>
         <td class="xxjbb_mc"><b>时间</b></td>
         <td class="xxjbb_mccc"><b>操作</b></td>
      </tr>
      <tr>
         <td class="xxjbb_6a">文件名</td>
         <td class="xxjbb_6a">文件描述</td>
         <td class="xxjbb_6a">上传人</td>
         <td class="xxjbb_6a">时间</td>
         <td class="xxjbb_6b"><a href="#">删除</a></td>
      </tr>
    </table>
</div>
 -->
</body>
</html>
